<script type="text/javascript" src="module/mod_keluarga/js/combo.js"></script>
<script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
</script>

<div id="tiga_ba">
	<div id="tiga_baa">Ubah Data Keluarga</div>
	<div id="tiga_bab"></div>
	<div class="clear"></div>
</div>
            
<?php
	$id=$_GET['id'];
	$sql="select * from keluarga k inner join desa d on k.id_desa = d.id_desa inner join kecamatan kc on d.id_kecamatan = kc.id_kecamatan inner join kabupaten kb on kc.id_kabupaten = kb.id_kabupaten inner join propinsi p on kb.id_propinsi = p.id_propinsi where k.id_kk = '$id'";
	$qry=mysql_query($sql);
	$hasil=mysql_fetch_array($qry);
?>
<form action="utama.php?module=mod_keluarga&act=update" onsubmit="return gsValidate('alamat|rt|rw|kabupaten|kecamatan|desa|datepicker','Alamat Harus Diisi|RT Harus Diisi|RW Harus Diisi|Nama Kabupaten Harus Dipilih|Nama Kecamatan Harus Dipilih|Nama Desa Harus Dipilih|Tangga Dikeluarkan Harus Diisi','required|required|required|required|required|required|required');" method="post" enctype="multipart/form-data">
	<table style="margin: 10px 15px 10px 15px;">
		<tr>
			<td>ID KK</td>
			<td>&nbsp;</td>
			<td>
				<input name="kode" type="text" id="kode" value="<?php echo $hasil['id_kk']?>" class="input2" disabled/>
				<input name="id_kk" type="hidden" id="id_kk" value="<?php echo $hasil['id_kk']?>" class="input2"/>
			</td>
		</tr>
		<tr>
			<td>Alamat</td>
			<td>&nbsp;</td>
			<td>
				<input name="alamat" type="text" class="input2" id="alamat" maxlength="255" value="<?php echo $hasil['alamat']?>"/>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>RT</td>
			<td>&nbsp;</td>
			<td>
				<input name="rt" type="text" class="input_small" id="rt" maxlength="5" value="<?php echo $hasil['rt']?>"/>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>RW</td>
			<td>&nbsp;</td>
			<td>
				<input name="rw" type="text" class="input_small" id="rw" maxlength="5" value="<?php echo $hasil['rw']?>"/>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>Provinsi</td>
			<td>&nbsp;</td>
			<td>
				<select name="provinsi" id="provinsi" class="input2">
				<?php 
					$provinsi = mysql_query("select * from propinsi where aktif = 'Y' order by propinsi");
					while($p = mysql_fetch_array($provinsi)){
						if($p['id_propinsi'] == $hasil['id_propinsi']){
							$s = "selected";
						}else{
							$s = "";
						}
						echo "<option value='$p[id_propinsi]' $s>$p[propinsi]</option>";
					} 
				?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Kabupaten</td>
			<td>&nbsp;</td>
			<td>
				<select name="kabupaten" id="kabupaten" class="input2">
					<?php
						$kabupaten = mysql_query("select * from kabupaten where id_propinsi = $hasil[id_propinsi] order by kabupaten");
						while($k = mysql_fetch_array($kabupaten)){
							if($k['id_kabupaten'] == $hasil['id_kabupaten']){
								$sk = "selected";
							}else{
								$sk = "";
							}
							echo "<option value='$k[id_kabupaten]' $sk>$k[kabupaten]</option>";
						}
					?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>Kecamatan</td>
			<td>&nbsp;</td>
			<td>
				<select name="kecamatan" id="kecamatan" class="input2">
					<?php
						$kecamatan = mysql_query("select * from kecamatan where id_kabupaten = $hasil[id_kabupaten] order by kecamatan");
						while($kc = mysql_fetch_array($kecamatan)){
							if($kc['id_kecamatan'] == $hasil['id_kecamatan']){
								$sk = "selected";
							}else{
								$sk = "";
							}
							echo "<option value='$kc[id_kecamatan]' $sk>$kc[kecamatan]</option>";
						}
					?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>Desa</td>
			<td>&nbsp;</td>
			<td>
				<select name="desa" id="desa" class="input2">
					<?php
						$desa = mysql_query("select * from desa where id_kecamatan = '$hasil[id_kecamatan]' order by desa");
						while($d = mysql_fetch_array($desa)){
							if($d['id_desa'] == $hasil['id_desa']){
								$sk = "selected";
							}else{
								$sk = "";
							}
							echo "<option value='$d[id_desa]' $sk>$d[desa]</option>";
						}
					?>
				</select>
				<span class="red">*</span>
			</td>
		</tr>
		<tr>
			<td>Dikeluarkan</td>
			<td>&nbsp;</td>
			<td>
				<input name="tgl" type="text" id="datepicker" value="<?php echo tgl_ind3("$hasil[tanggal_dikeluarkan]");?>" class="input2"/>
				<span class="red">*</span>
			</td>
		</tr>
		<!--<tr>
			<td>Jamkesmas</td>
			<td>&nbsp;</td>
			<td>
				<?php
					if($hasil['jamkesmas'] == 'Y'){
						$y = "checked";
						$n = "";
					}else{
						$y = "";
						$n = "checked";
					}
				?>
				<input type="radio" name="jamkesmas" value="Y" <?php echo $y; ?>>Ya
				<input type="radio" name="jamkesmas" value="N" <?php echo $n; ?>>Tidak
			</td>
		</tr>-->
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td><input name="submit" type="submit" class="button" value="Ubah" /></td>
		</tr>
	</table>
</form>		
            
        